#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more 
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership. 
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with 
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace IPSim.Data
{
    public class ICMPPacket : IIPData
    {
        private readonly ICMPTypes m_type;
        private readonly byte m_code;
        private IPAddress m_srcIPAddr;
        private readonly ushort m_id;
        private readonly ushort m_sequence;

        public ICMPPacket(ICMPTypes type, byte code, ushort id, ushort sequence)
        {
            m_type = type;
            m_code = code;
            m_id = id;
            m_sequence = sequence;
        }

        public ICMPTypes Type
        {
            get
            {
                return m_type;
            }
        }

        public byte Code
        {
            get
            {
                return m_code;
            }
        }

        public ushort ID
        {
            get
            {
                return m_id;
            }
        }

        public ushort Sequence
        {
            get
            {
                return m_sequence;
            }
        }

        public IPAddress SenderIPAddress
        {
            get
            {
                return m_srcIPAddr;
            }
            set
            {
                m_srcIPAddr = value;
            }
        }

        public enum ICMPTypes : byte
        {
            EchoReply = 0,
            DestinationUnreachable = 3,
            EchoRequest = 8,
            TimeExceeded = 11,
        }

        public Type DeclaringType
        {
            get
            {
                return declaringType;
            }
        }

        private readonly static Type declaringType = typeof(ICMPPacket);
    }
}
